//
//  main.cpp
//  继承和派生
//
//  Created by Robin Guo on 2017/9/23.
//  Copyright © 2017年 Robin Guo. All rights reserved.
//

#include <iostream>

using namespace std;

class Point {
private:
    float x,y;
    
public:
    Point(float a,float b){
        x=a;
        y=b;
    }
    void show() {
        cout << "x: " << x << " y: " << y << endl;
    }
    
    float getX() {
        return x;
    }
    
    float getY() {
        return y;
    }
};

class RectAngle: public Point {
private:
    float W;
    float H;
    
public:
    RectAngle(float a,float b,float w,float h):Point(a,b) {
        W = w;
        H = h;
    }
    
    void show() {
        cout << "x : " << this->getX() << " y: " << this->getY() << " w: " << W << " h: " << H << endl;
    }
};

int main(int argc, const char * argv[]) {
    // 赋值兼容性规则：在公有继承的情况下派生类的对象当做基类对象使用的情况；
    Point a(10,20);
    RectAngle c(30,34,34.3,43);
    
    a.show();
    c.show();
    
    a=c;
    a.show();
    
    return 0;
}
